import { Behaviour, HitTestScript, getGameObjectById } from "../gameengine";
import { user } from "../user";
import { ColliderSystem } from "../rect/ColliderSystem";
import { RectCollider, RectColliderType } from "../rect/RectCollider";

export class cao extends Behaviour {

    protected onStart() {



    }

    protected onUpdate(advancedTime: number) {
        const colliderSystem = getGameObjectById("Scene").getScript(ColliderSystem);
        const collider = this.displayObject.getScript(RectCollider);
        const nextCollider = {
            left: collider.left + -4,
            right: collider.right + 4,
            top: collider.top + -4,
            bottom: collider.bottom + 4
        }
        const hitTestResult1 = colliderSystem.check(nextCollider, RectColliderType.MAINROLE);
        if (hitTestResult1) {
            console.log("1")
            this.displayObject.parent.removeChild(this.displayObject);
            user.getCao = true;
        }



    }



}